<?
/**
 * GDataGridSorter
 *
 * This class file helps out with common file handling functions and tasks.
 *
 * @author Lars Sorhus (lars@saucecode.com.au)
 * @internal It's not recommended at all to modify this code.
 * @package GDataGrid
 */
class GDataGridSorter{
	var $gravy;
	var $orderByVariableName="orderBy";
	var $sortByVariableName="direction";
	var $class_off="col_off", $class_asc="col_asc", $class_desc="col_desc";
	public function __construct(application $gravy){
		$this->gravy=$gravy;
	}

	public function setHeaderClasses($off="col_off",$asc="col_asc",$desc="col_desc"){
		$this->class_off=$off;
		$this->class_asc=$asc;
		$this->class_desc=$desc;
	}

	public function getUrl($col){
		$sortOrder="asc";
		if($this->gravy->rv[$this->orderByVariableName]==$col&&strtolower($this->gravy->rv[$this->sortByVariableName])=="asc"){
			$sortOrder="desc";
		}
		return($this->gravy->getUrl(true,$this->orderByVariableName."=".$col."&".$this->sortByVariableName."=".$sortOrder."&axn="));
	}

	public function getClass($col){
		$result=false;
		if($this->gravy->rv[$this->orderByVariableName]==$col){
			if($this->gravy->rv[$this->sortByVariableName]=="desc"||$this->gravy->rv[$this->sortByVariableName]==1){
				$result=$this->class_desc;
			}else{
				$result=$this->class_asc;
			}
		}else{
			$result=$this->class_off;
		}
		return($result);
	}
};
?>
